package com.letv.app.ljodfh.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.letv.app.ljodfh.R;
import com.letv.app.ljodfh.beans.NewsItem;
import com.letv.app.ljodfh.ui.adapter.holder.BaseAbsHolder;
import com.letv.app.ljodfh.ui.adapter.holder.OnlyTitleHolder;
import com.letv.app.ljodfh.ui.adapter.holder.TopicHomeHolder;

import java.util.List;

/**
 * Created by liuyu on 2017/11/20.
 */

public class TopicHomeAdapter extends BaseHolderAbsAdapter<NewsItem, BaseAbsHolder<NewsItem>> {

    public static final int TYPE_TITLE = 35;

    public TopicHomeAdapter(Context context, List<NewsItem> list) {
        super(context, list);
    }

    @Override
    public BaseAbsHolder<NewsItem> onCreateViewHolder(ViewGroup parent, int viewType) {
        BaseAbsHolder holder = null;
        if (viewType == TYPE_TITLE) {
            View v = LayoutInflater.from(context).inflate(R.layout.item_live_title, parent, false);
            holder = new OnlyTitleHolder(context, v, true);
        } else {
            View v = LayoutInflater.from(context).inflate(R.layout.item_topic_home, parent, false);
            holder = new TopicHomeHolder(context, v);
        }
        return holder;
    }

    @Override
    public int getItemViewType(int position) {
        NewsItem ni=getItem(position);
        if (ni!=null){
            return ni.getDataViewType();
        }
        return super.getItemViewType(position);
    }
}
